<template>
  <div id="tsl-pie" style="width:400px; height:350px;"></div>
</template>

<script>
export default {
  methods: {
    tsl() {
      var myChart = this.$echarts.init(document.getElementById('tsl-pie'));
      var option = {
        toolbox: {
          show: true,
           feature: {
            dataView: { show: true, readOnly: false },
            restore: { show: true },
            saveAsImage: { show: true, backgroundColor: 'black' }
          },
          iconStyle: {
             borderColor: 'white'
          },
          right: '30px'
        },
        title: {
          text: '评论情绪占比',
          left: 'center',
          textStyle: {
            color: 'orange'
          }
        },
        tooltip: {
          trigger: 'item'
        },
        legend: {
          bottom: '5%',
          left: 'center',
          textStyle: {
            color: "white"
          }
        },
        series: [
          {
            type: 'pie',
            radius: ['40%', '70%'],
            avoidLabelOverlap: false,
            itemStyle: {
              borderRadius: 5,
              borderColor: '#fff',
              borderWidth: 2
            },
            label: {
              show: true,
              position: 'outside',
              color: 'white',
              formatter: '{d}%'
            },
            emphasis: {
              label: {
                show: false,
                fontSize: 40,
                fontWeight: 'bold'
              }
            },
            labelLine: {
              show: true,
              length:1
            },
            data: [
              { value: 579, name: '积极' },
              { value: 182, name: '消极' },
              { value: 58, name: '中立' },
            ]
          }
        ]
      };
      myChart.setOption(option);
    },
  },
  mounted() {
    this.tsl()
  },
}
</script>

<style>

</style>